﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace clock.time

{
    public class ReflectionFunction
    {

        // C#反射遍历对象属性

        public static List<object[]> ForeachClassProperties<T>(T model)
        {
            List<object[]> stritems = new List<object[]>();
            Type t = model.GetType();
            PropertyInfo[] PropertyList = t.GetProperties();
            foreach (PropertyInfo item in PropertyList)
            {
                object[] items = new object[] { item.Name, item.GetValue(model, null) };
                stritems.Add(items);
            }
            return stritems;
        }

    }
}
